//$(document).ready();


$(function (){
    //alert("加载完成");
    var rootUrl = "http://127.0.0.1/";
    var txtUrl = "http://127.0.0.1/hk.txt";
    //jq_ajax   
    /*    
    $("#content1").load(txtUrl);
    
    $("ajax_test").click(function(){
        $.get("demo_test.php",function(data,status){
        alert("数据: " + data + "\n状态: " + status);
        });
    });
    
    //设置jq简写和释放$符号，避免其他框架冲突
    //var jq=$.noConflic();
    
    //jsonp 跨域调用
    $.getJSON(txtUrl,function (data){
        alert("getJSON:"+data);
    });
    */
    //实现展开式的菜单
    var listData={
        data1:{data:['简介','安装','Hello world'],btn:"第一章"},
        data2:{data:['数据类型','语句','函数'],btn:"第二章"},
        data3:{data:['字符串、数组、字典讲解','面向对象','网络编程'],btn:"第三章"},
        data4:{data:['web实践','游戏实践','总结'],btn:"第四章"}
    }
    $("button").addClass("btns");
    
    $("#listContent1").slideDown(0);
    var preId = 1;
    $("#content1 button").click(function (){        
        var id = parseInt(this.id.charAt(this.id.length-1));
        var listId="#listContent"+id;
        $(listId).slideDown();
        var alls = $(listId+" ul li").children();        
        for(var i=0;i<alls.length;i++)
        {           
            var html = listData['data'+id]['data'][i];
            var href="https://www.baidu.com/s?wd=";            
            $(alls[i]).html(html).attr("href",href+html).attr("target","_blank");            
        } 
        
        if(preId>-1)
        {
            $("#listContent"+preId).slideUp();
        }
        if(preId===id)
        {
            preId = -1;
        }else
        {
            preId = id;
        }        
    });
    
   
    
});